<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>用户</title>
<script type="text/javascript">
function upImage(){
	$("#imgForm").ajaxSubmit({
		dataType : "json",
		success : function(data) {
			if (data.success == true) {
				var url = data.msg;
				$("#imgId").attr("src",url);
				$("#photo").val(url);
			} else {
				alert(data.msg);
			}
		}
	});
}
$(function(){
	$("#form").validate({
		ignore:".ignore",//出去class = ignore的表单不验证，其他的隐藏表单都可以验证
		rules : {
			"photo" : {
				required : true,
			},
			"name" : {
				required : true
			}
		},
		messages : {
			"photo" : {
				required : "请上传作品"
				
			},
			"name" : {
				required : "请输入作品名称"
			}
		},
		errorPlacement : function(error, element) {//错误信息显示位置
			if (element.attr("name") == "photo") {
				error.css("left", $("#upBtn").width() + 30);
				error.appendTo($("button[name='upBtn']"));
			} else {
				error.insertAfter(element);
			}
		}
	});
	$("#submitBtn").on("click",function(){
		$("#form").submit();
	});
});
</script>
</head>
<body>
	<ol class="am-breadcrumb am-breadcrumb-slash am-padding" style="margin-bottom: 0px;">
		<li><a href="management/index">首页</a></li>
		<li><a href="management/employee/worksindex">作品库及休息日管理</a></li>
		<li><a href="management/employee/worksmanagement/"+${employeeId }>作品库管理</a></li>
		<li class="am-active">新增</li>
	</ol>
	<div class="am-g">
		<div class="am-u-md-12">
				<div class="am-tabs am-margin">
					<ul class="am-tabs-nav am-nav am-nav-tabs">
						<li class="am-active"><a href="javascript:void(0)">基本信息</a></li>
					</ul>
					<div class="am-tabs-bd">
						<div class="am-tab-panel am-active">
							<div>
								<div class="am-u-sm-12">
									<form id="imgForm" class="am-form am-form-horizontal am-block" action="management/file" method="post" enctype="multipart/form-data">
										<label class="am-u-sm-2 am-form-label">作品照片</label>
										<div class="am-u-sm-4 am-u-end">
											<img id="imgId" src="file/a.png" class="am-form-field">
											<div class="am-form-group am-form-file">
												<button id="upBtn" name="upBtn" type="button" class="am-btn am-btn-default">
													<i class="am-icon-cloud-upload"></i> 选择要上传的图片
												</button>
												<input name="imageFile" id="imageFile" onchange="upImage();" type="file" multiple>
											</div>
										</div>
									</form>
								</div>
								<div class="am-u-sm-12">
									<form class="am-form am-form-horizontal" id="form" name="form"  method="post" action="management/employee/workssave">
										<!-- <input type="text" name="photo" id="photo" style="height:0; width:0; border:0;visibility: hidden"> -->
										<input type="hidden" name="photo" id="photo" >
										<input type="hidden" name="employeeId" id="employeeId" value="${employeeId }" class="am-form-field am-input-sm"><!-- pshopId -->
										<div class="am-form-group">
											<label class="am-u-sm-2 am-form-label">作品名称</label>
											<div class="am-u-md-4 am-u-end">
												<input type="text" id="name" name="name" class="am-form-field am-input-sm">
											</div>
										</div>
									</form>	
								</div>
							</div>	
						</div>
					</div>
				</div>
				<div class="am-margin">
					<button class="am-btn am-btn-primary am-btn-xs" type="button" id="submitBtn"><span class="am-icon-check"></span> 保存</button>
					<a href="javascript:;" onClick="javascript:history.back(-1);" class="am-btn am-btn-primary am-btn-xs"><span class="am-icon-times"></span> 取消</a>
				</div>
		</div>
	</div>
</body>
</html>
